//将接口封装成api
import service from "@/service";
import axios from "axios";
import form from "vue-resource/src/http/interceptor/form";
/*登录接口*/
export function login(data){
    return service({
        method: 'post',
        url: 'login',
        data
    })
}
/*免登录接口*/
export function login_free(){
    return service({
        method:'post',
        url:'login-by-token',
    })
}
/*得到博客id列表*/
export function getBlogs(str,userId){
    return service({
        method: 'get',
        url: 'user/index/someType/'+str + '/' + userId,
    })
}
/*得到单独的博客*/
export function getBlog(blogId){
    return service({
        method: 'get',
        url: 'user/get-blog/'+blogId,
    })
}
/*得到评论接口*/
export function getComment(blogId,commentId){
    return service({
        method: 'get',
        url: 'comment/get-comment/'+ blogId + '/' + commentId,
    })
}
/*写评论*/
export function setComment(comment){
    return service({
        method:'post',
        url:'comment/add-comment',
        data:comment,
    })
}

export function getHot(str){
    return service({
        method:'get',
        url:'user/hot/some-type/'+str,
    })
}
/*得到用户信息*/
export function getUser(Id){
    return service({
        method:'get',
        url:'user/get-user/'+Id,
    })
}
/*注册接口*/
export function sendRegister(form){
    return service({
        method:'post',
        url:'register',
        data:form,
    })
}
/*写博客文件上传接口*/
export function uploadFile(data){
    return service({
        method:'post',
        url:'upload-file',
        headers: { "Content-Type": "multipart/form-data"},
        data
    })
}
/*写博客信息接口*/
export function setBlog(blog){
    return service({
        method:'post',
        url:'blog/add-blog',
        data:blog
    })
}
/*评论数和点赞数接口*/
export function getCount(blogId){
    return service({
        method:'get',
        url:'blog/get-likes-and-comments-num/' + blogId,
    })
}

/*修改用户信息*/
export function setUser(user){
    return service({
        method:'post',
        url:'/user/modify-user-info',
        data:user,
    })
}

/*获取粉丝用户id列表或者关注用户id列表*/
export function getUserList(str){
    return service({
        method:'get',
        url:'user/user-index/' + str
    })
}


/*点过赞的博客id列表*/
export function thumbsUpBlog(){
    return service({
        method:'get',
        url:'blog/get-liked-blog-ids',
    })
}

/*点赞功能*/
export function thumbsUp(userId,blogId){
    return service({
        method:'get',
        url:'like/like/' + userId + '/' + blogId
    })
}

/*取消点赞功能*/
export function NoThumbsUp(userId,blogId){
    return service({
        method:'get',
        url:'like/unlike/' + userId + '/' + blogId ,
    })
}

export function interestUser(){
    return service({
        method:'get',
        url:'user/maybe-interest-user'
    })
}
/*关注用户*/
export function concern(blogId){
    return service({
        method:'get',
        url:'/user/concern/'+blogId
    })
}










